a = 0  # 是全局变量
def f():
    a = 1 # a是局部变量
    def g():
        # nonlocal a
        global  a
        a +=1
        print(a)
    g()
f() # 输出 a=2
